package cn.NewsServlet;

import cn.NewsDao.NewsDao1;
import cn.NewsDaoImpl.NewsDaoImpl1;
import cn.NewsService.NewsService1;
import cn.NewsServiceImpl.NewsServiceImpl1;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class ElectServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        String newsid = req.getParameter("newsid");
        if (newsid != null || newsid != "") {
            int newId = Integer.parseInt(newsid);

            NewsService1 newsService1 = new NewsServiceImpl1();
            if (newsService1.deleteNews(newId)) {
                resp.sendRedirect(req.getContextPath() + "/index2.jsp");
            } else {
                System.out.println("这是get请求");
            }
        }
    }
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        System.out.println("这是post请求");
    }
}
